
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../utils/Settings.dart';
import '../../utils/Utils.dart';
import '../formitems/cascader/LFormCascaderLogic.dart';
import '../formitems/cascader/LFormCascaderPage.dart';
import '../formitems/date/LFormDateLogic.dart';
import '../formitems/date/LFormDatePage.dart';
import '../formitems/datetime/LFormDatetimeLogic.dart';
import '../formitems/datetime/LFormDatetimePage.dart';
import '../formitems/input/LFormInputLogic.dart';
import '../formitems/input/LFormInputPage.dart';
import '../formitems/month/LFormMonthLogic.dart';
import '../formitems/month/LFormMonthPage.dart';
import '../formitems/multicascader/LFormMultiCascaderLogic.dart';
import '../formitems/multicascader/LFormMultiCascaderPage.dart';
import '../formitems/multiselect/LFormMultiSelectLogic.dart';
import '../formitems/multiselect/LFormMultiSelectPage.dart';
import '../formitems/select/LFormSelectLogic.dart';
import '../formitems/select/LFormSelectPage.dart';
import '../formitems/time/LFormTimeLogic.dart';
import '../formitems/time/LFormTimePage.dart';
import '../formitems/year/LFormYearLogic.dart';
import '../formitems/year/LFormYearPage.dart';
import '../get/MyController.dart';
import '../list/LCellListLogic.dart';
import 'LQueryFormState.dart';

class LQueryFormLogic extends GetxController{

  final state = LQueryFormState();

  //存放此QUERYFORM中的所有controller;
  final List<MyController> controllerList = [];

  void init({required List queryFormAttributes,required Map queryFromData,required String tag,Function? queryCallback,Function? resetCallback}){
    state.queryFormAttributes = queryFormAttributes;
    state.queryFromData = queryFromData;
    state.tag = tag;
    state.formKey =  GlobalKey<FormState>();
    state.queryCallback = queryCallback;
    state.resetCallback = resetCallback;
    controllerList.clear();

  }

  ///生成表单中的组件
  List<Widget> createFormItes(){
    List<Widget> itemList = [];
    for(dynamic item in state.queryFormAttributes){
      if(item["component"]=="input"){
        itemList.add(createTextFormField(item)) ;
      } else if(item["component"]=="select"){
        itemList.add(createSelectFormField(item)) ;
      }else if(item["component"]=="date"){
        itemList.add(createDateFormField(item));
      }else if(item["component"]=="time"){
        itemList.add(createTimeFormField(item));
      }else if(item["component"]=="datetime"){
        itemList.add(createDateTimeFormField(item));
      }else if(item["component"]=="year" ){
        itemList.add(createYearFormField(item));
      }else if(item["component"]=="month"){
        itemList.add(createMonthFormField(item));
      }else if(item["component"]=="cascader"){
        itemList.add(createCascaderFormField(item)) ;
      }else if(item["component"]=="multiselect"){
        itemList.add(createMultiSelectFormField(item));
      }else if(item["component"]=="multicascader"){
        itemList.add(createMultiCascaderFormField(item));
      }
    }
    return itemList.toList();
  }



  ///生成输入框
  Widget createTextFormField(item){
    if(item["condition"]!="between"){
      final LFormInputLogic formInputlogic = Get.put(LFormInputLogic(),tag: '${state.tag}#${item['field']}');
      formInputlogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(formInputlogic);
      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: LFormInputPage(tag: '${state.tag}#${item['field']}',)),
          const Divider(),
        ],
      );
    }else{
      final LFormInputLogic formInputlogicSt = Get.put(LFormInputLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      formInputlogicSt.init(formItem: item, formData: state.queryFromData,betweenSign:Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(formInputlogicSt);

      final LFormInputLogic formInputlogicEt = Get.put(LFormInputLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      formInputlogicEt.init(formItem: item, formData: state.queryFromData,betweenSign:Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"] );
      controllerList.add(formInputlogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:Row(
            children: [
              Expanded(flex:10,child:LFormInputPage(tag: '${state.tag}#${item['field']}${Settings.stSign}' ,)),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormInputPage(tag: '${state.tag}#${item['field']}${Settings.etSign}',)),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }


  }

  ///生成下拉
  Widget createSelectFormField(item){
    if(item["condition"]!="between"){
      final LFormSelectLogic lFormSelectLogic = Get.put(LFormSelectLogic(),tag: '${state.tag}#${item['field']}');
      lFormSelectLogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormSelectLogic);
      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:LFormSelectPage(tag: '${state.tag}#${item['field']}',),),
          const Divider(),
        ],
      );
    }else{
      final LFormSelectLogic lFormSelectLogicSt = Get.put(LFormSelectLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormSelectLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormSelectLogicSt);

      final LFormSelectLogic lFormSelectLogicEt = Get.put(LFormSelectLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormSelectLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormSelectLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: Row(
            children: [
              Expanded(flex:10,child:LFormSelectPage(tag: '${state.tag}#${item['field']}${Settings.stSign}',),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormSelectPage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }

  }

  ///生成多选下拉
  Widget createMultiSelectFormField(item){
    if(item["condition"]!="between"){
      final LFormMultiSelectLogic lFormMultiSelectLogic = Get.put(LFormMultiSelectLogic(),tag: '${state.tag}#${item['field']}');
      lFormMultiSelectLogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMultiSelectLogic);
      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:LFormMultiSelectPage(tag: '${state.tag}#${item['field']}',),),
          const Divider(),
        ],
      );
    }else{
      final LFormMultiSelectLogic lFormMultiSelectLogicSt = Get.put(LFormMultiSelectLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormMultiSelectLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMultiSelectLogicSt);

      final LFormMultiSelectLogic lFormMultiSelectLogicEt = Get.put(LFormMultiSelectLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormMultiSelectLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMultiSelectLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: Row(
            children: [
              Expanded(flex:10,child:LFormMultiSelectPage(tag: '${state.tag}#${item['field']}${Settings.stSign}',),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormMultiSelectPage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }

  }

  ///树形选择
  Widget createCascaderFormField(item){
    if(item["condition"]!="between"){
      final LFormCascaderLogic lFormCascaderLogic = Get.put(LFormCascaderLogic(),tag: '${state.tag}#${item['field']}');
      lFormCascaderLogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormCascaderLogic);
      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:LFormCascaderPage(tag: '${state.tag}#${item['field']}'),),
          const Divider(),
        ],
      );
    }else{
      final LFormCascaderLogic lFormCascaderLogicSt = Get.put(LFormCascaderLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormCascaderLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormCascaderLogicSt);

      final LFormCascaderLogic lFormCascaderLogicEt = Get.put(LFormCascaderLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormCascaderLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormCascaderLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: Row(
            children: [
              Expanded(flex:10,child:LFormCascaderPage(tag: '${state.tag}#${item['field']}${Settings.stSign}',),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormCascaderPage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }

  }

  ///树形多选选
  Widget createMultiCascaderFormField(item){
    if(item["condition"]!="between"){
      final LFormMultiCascaderLogic lFormMultiCascaderLogic = Get.put(LFormMultiCascaderLogic(),tag: '${state.tag}#${item['field']}');
      lFormMultiCascaderLogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMultiCascaderLogic);
      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:LFormMultiCascaderPage(tag: '${state.tag}#${item['field']}'),),
          const Divider(),
        ],
      );
    }else{
      final LFormMultiCascaderLogic lFormMultiCascaderLogicSt = Get.put(LFormMultiCascaderLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormMultiCascaderLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMultiCascaderLogicSt);

      final LFormMultiCascaderLogic lFormMultiCascaderLogicEt = Get.put(LFormMultiCascaderLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormMultiCascaderLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMultiCascaderLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: Row(
            children: [
              Expanded(flex:10,child:LFormMultiCascaderPage(tag: '${state.tag}#${item['field']}${Settings.stSign}',),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormMultiCascaderPage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }

  }

  ///日期选择
  Widget createDateFormField(item){
    if(item["condition"]!="between"){
      final LFormDateLogic lFormDateLogic = Get.put(LFormDateLogic(),tag: '${state.tag}#${item['field']}');
      lFormDateLogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormDateLogic);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:LFormDatePage(tag: '${state.tag}#${item['field']}',),),
          const Divider(),
        ],
      );
    }else{
      final LFormDateLogic lFormDateLogicSt = Get.put(LFormDateLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormDateLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormDateLogicSt);

      final LFormDateLogic lFormDateLogicEt = Get.put(LFormDateLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormDateLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormDateLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: Row(
            children: [
              Expanded(flex:10,child:LFormDatePage(tag: '${state.tag}#${item['field']}${Settings.stSign}',),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormDatePage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }

  }

  ///时间选择
  Widget createTimeFormField(item){
    if(item["condition"]!="between"){
      final LFormTimeLogic lFormTimeLogic = Get.put(LFormTimeLogic(),tag: '${state.tag}#${item['field']}');
      lFormTimeLogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormTimeLogic);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: LFormTimePage(tag: '${state.tag}#${item['field']}',),),
          const Divider(),
        ],
      );
    }else{
      final LFormTimeLogic lFormTimeLogicSt = Get.put(LFormTimeLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormTimeLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormTimeLogicSt);

      final LFormTimeLogic lFormTimeLogicEt = Get.put(LFormTimeLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormTimeLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormTimeLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:Row(
            children: [
              Expanded(flex:10,child:LFormTimePage(tag: '${state.tag}#${item['field']}${Settings.stSign}',),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormTimePage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }
  }

  ///年月日时分秒
  Widget createDateTimeFormField(item){
    if(item["condition"]!="between"){
      final LFormDatetimeLogic lFormDatetimeLogic = Get.put(LFormDatetimeLogic(),tag: '${state.tag}#${item['field']}');
      lFormDatetimeLogic.init(formItem: item, formData: state.queryFromData,betweenSign: "",formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormDatetimeLogic);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:LFormDatetimePage(tag: '${state.tag}#${item['field']}',),
          ),
          const Divider(),
        ],
      );
    }else{
      final LFormDatetimeLogic lFormDatetimeLogicSt = Get.put(LFormDatetimeLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormDatetimeLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormDatetimeLogicSt);

      final LFormDatetimeLogic lFormDatetimeLogicEt = Get.put(LFormDatetimeLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormDatetimeLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormDatetimeLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:Row(
            children: [
              Expanded(flex:11,child:LFormDatetimePage(tag: '${state.tag}#${item['field']}${Settings.stSign}'),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:11,child:LFormDatetimePage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }

  }

  ///年
  Widget createYearFormField(item){
    if(item["condition"]!="between"){
      final LFormYearLogic lFormYearLogic = Get.put(LFormYearLogic(),tag: '${state.tag}#${item['field']}');
      lFormYearLogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormYearLogic);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: LFormYearPage(tag: '${state.tag}#${item['field']}',),),
          const Divider(),
        ],
      );
    }else{
      final LFormYearLogic lFormYearLogicSt = Get.put(LFormYearLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormYearLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormYearLogicSt);

      final LFormYearLogic lFormYearLogicEt = Get.put(LFormYearLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormYearLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormYearLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: (item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],)),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:Row(
            children: [
              Expanded(flex:10,child:LFormYearPage(tag: '${state.tag}#${item['field']}${Settings.stSign}',),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormYearPage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }

  }
  ///月
  Widget createMonthFormField(item){
    if(item["condition"]!="between"){
      final LFormMonthLogic lFormMonthLogic = Get.put(LFormMonthLogic(),tag: '${state.tag}#${item['field']}');
      lFormMonthLogic.init(formItem: item, formData: state.queryFromData,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMonthLogic);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child: LFormMonthPage(tag: '${state.tag}#${item['field']}',),),
          const Divider(),
        ],
      );
    }else{
      final LFormMonthLogic lFormMonthLogicSt = Get.put(LFormMonthLogic(),tag: '${state.tag}#${item['field']}${Settings.stSign}');
      lFormMonthLogicSt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.stSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMonthLogicSt);

      final LFormMonthLogic lFormMonthLogicEt = Get.put(LFormMonthLogic(),tag: '${state.tag}#${item['field']}${Settings.etSign}');
      lFormMonthLogicEt.init(formItem: item, formData: state.queryFromData,betweenSign: Settings.etSign,formTag: state.tag,formType: Settings.formType["查询表单"]);
      controllerList.add(lFormMonthLogicEt);

      return Column(
        crossAxisAlignment:CrossAxisAlignment.start,
        children: [
          Padding(padding: const EdgeInsets.all(10),child: item["required"]==true?Row(children: [const Icon(Icons.star,color: Colors.red,size: 10,),Text(item["label"])]):Row(children: [const SizedBox(width: 10,),Text(item["label"])],),),
          Padding(padding: const EdgeInsets.only(left: 20,right: 20),child:Row(
            children: [

              Expanded(flex:10,child:LFormMonthPage(tag: '${state.tag}#${item['field']}${Settings.stSign}',),),
              const Expanded(flex:1,child:Text('-'),),
              Expanded(flex:10,child:LFormMonthPage(tag: '${state.tag}#${item['field']}${Settings.etSign}',),),
            ],
          ),
          ),
          const Divider(),
        ],
      );
    }

  }

  void reset(){
    ///如果传入的有查询回调，则直接调用
    if(state.resetCallback!=null){
      state.resetCallback!(state.queryFromData);
      Get.back();
      return;
    }

    if(Utils.isEmpty(state.listTag)){
      Get.back();
      return;
    }
    var form = state.formKey.currentState as FormState;
    if(form.validate()){
      form.reset();
      state.queryFromData.clear();
      for(int i=0;i<controllerList.length;i++){
        controllerList[i].reset();
      }
      ///调用查询方法
      Get.put(LCellListLogic(),tag: state.listTag).onRefresh();
      Get.back();


    }
  }

  void query(){
    ///如果传入的有查询回调，则直接调用
    if(state.queryCallback!=null){
      state.queryCallback!(state.queryFromData);
      Get.back();
      return;
    }

    if(Utils.isEmpty(state.listTag)){
      Get.back();
      return;
    }
    var form = state.formKey.currentState as FormState;
    if(form.validate()){
      ///调用查询方法
      Get.put(LCellListLogic(),tag: state.listTag).onRefresh();
      Get.back();
    }
  }

  void setQueryFromData(queryFromData){
    state.queryFromData = queryFromData;
    update();
  }

  void onChange(changeItem){}
}